// function Coder(name, age) { //录入每个程序员的信息
// 	this.name = name;
// 	this.age = age;
// 	this.career = 'coder';
// 	this.work = ['写代码', '改bug', '马产品'];
// }

// function ProductManager(name, age) { //录入每个管理员的信息
// 	this.name = name;
// 	this.age = age;
// 	this.career = 'product manager';
// 	this.work = ['定会议室', '画原型图', '催更'];
// }

// // 工厂诞生
// function Factory(name, age, career) {
// 	switch (career) {
// 		case 'coder':
// 			return new Coder(name, age);
// 			break;
// 		case 'product manager':
// 			return new ProductManager(name, age);
// 			break;
// 	}
// }
// // 得到实例
// const coder1 = new Factory('linda', 19, 'coder')
// const manager1 = new Factory('boss1', 32, 'product manager')
// console.log(coder1);
// console.log(manager1);


// 改进后的工厂（有构造函数的地方）
function User(name, age, career, work) {
	this.name = name;
	this.age = age;
	this.career = career;
	this.work = work;
}

function Factory(name, age, career) {
	switch (career) {
		case 'coder':
			work = ['写代码', '改bug', '马产品'];
			break;
		case 'product manager':
			work = ['定会议室', '画原型图', '催更'];
			break;
		default:
			work = ['守卫公司']
			break;
	}

	return new User(name, age, work, career)
}
const guider1 = new Factory('门卫叔叔', 43)
const coder1 = new Factory('程序员甲', 20, 'coder')
const manager1 = new Factory('管理员1', 40, 'product manager')
console.log(guider1, coder1, manager1);
